package com.indeep.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.indeep.user.mapper.po.AppUserSettingPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface AppUserSettingMapper extends BaseMapper<AppUserSettingPO> {

    @Update("update app_user_setting set individuation=#{individuation} where user_id =#{userId}")
    Integer updateIndividuation(AppUserSettingPO appUserSettingDO);

    @Select("select individuation from app_user_setting where user_id =#{userId}")
    Integer queryIndividuation(Long userId);


    // 修改震动情况
    @Update("<script>" +
            "update app_user_setting set " +
            "<if test='followDisplay !=null'>follow_display=#{followDisplay}, </if> "+
            "<if test='fansDisplay !=null'>fans_display=#{fansDisplay}, </if> "+
            "<if test='likeDisplay !=null'>like_display=#{likeDisplay}, </if> "+
            "<if test='beLikeDisplay !=null'>be_like_display=#{beLikeDisplay}, </if> "+
            "update_time=sysdate()"+
            "where user_id=#{userId}"+
            "</script>")
    Integer updateMyHomePrivacy(AppUserSettingPO myHomePrivacyDTO);

    @Update("update app_user_setting set last_view_time = now() where user_id = #{userId} ")
    void updatePostViewTime(Long userId);

    @Select("select credit from app_user_setting where user_id = #{userId} ")
    Integer getCreditByUserId(Long userId);
}
